package ${package.Controller};
import ${cfg.package_dir}.common.Result;
<#if cfg.mybatis  >
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import ${package.Service}.${table.serviceName};
import ${package.Entity}.${entity};
</#if>
<#if cfg.baseController>
import ${cfg.package_dir}.${cfg.cfgName}.BaseControllerConf;
</#if>
import org.springframework.web.bind.annotation.RequestMapping;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * ${table.comment!} 前端控制器
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if cfg.module_name_sub?? && cfg.module_name_sub != "">/${cfg.module_name_sub}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} <#if cfg.baseController> extends BaseControllerConf</#if> {
</#if>
    <#if  cfg.mybatis >
    @Autowired
    private ${table.serviceName} ${table.serviceName ? substring(1) ? uncap_first};

    @PostMapping("/save")
    public Result save(@RequestBody ${entity} ${entity ? uncap_first}) {
        ${table.serviceName ? substring(1) ? uncap_first}.save(${entity ? uncap_first});
        return Result.success(null);
    }

    @PostMapping("/update")
    public Result update(@RequestBody ${entity} ${entity ? uncap_first}) {
        ${table.serviceName ? substring(1) ? uncap_first}.update();
        return Result.success(null);
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable("id") Long id) {
        return Result.success(${table.serviceName ? substring(1) ? uncap_first}.getById(id));
    }

    @GetMapping("/list")
    public Result list(Object obj){
        ${table.serviceName ? substring(1) ? uncap_first}.list();
        return null;
    }
    </#if>

}
</#if>
